home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
130 MIDI Tool Box
/
130 MIDI Tool Box.iso
/
dac12x16
/
ftos12.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-09-23
|
443b
|
20 lines
/* ftos12--float to short for 12-bit DAC
* ftos12 < infile > outfile
*/
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define DAC12 2047 /* 2^12 / 2 - 1 */
main()
{
float x;
short y;
setmode(fileno(stdin), O_BINARY);
setmode(fileno(stdout), O_BINARY);
while (fread((char *)&x, sizeof(float), 1, stdin))
{ y = x * DAC12;
fwrite((char *)&y, sizeof(short), 1, stdout);
}
}